<?php

require_once dirname(__FILE__).'/../lib/partnerGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/partnerGeneratorHelper.class.php';

/**
 * partner actions.
 *
 * @package    billingSystem
 * @subpackage partner
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class partnerActions extends autoPartnerActions
{
        public function executeDeleteEmail(sfWebRequest $request) {
        $sub_category = Doctrine_Core::getTable('PartnerEmail')->where('email=?', $request->getParameter('id'));
        $sub_category->delete();
        $this->redirect('@partner_edit?id='.$this->getRoute()->getObject());
        }
    public function executeDeleteProduct(sfWebRequest $request) {
      $product =Doctrine_Core::getTable('PartnerProducts')->where ('pid=?',$this->getRoute()->getObject()->getPid())-> 
              andWherer('proid=?',$request->getParameter('id'));
      $product->delete();
      $this->redirect('@partner_edit?id='.$this->getRoute()->getObject());
    }
    public function executeDeleteLogin(sfWebRequest $request) {
      $login =Doctrine_Core::getTable('Login')->where ('pid=?',$this->getRoute()->getObject()->getPid());

      $login->delete();
      $this->redirect('@partner_edit?id='.$this->getRoute()->getObject());
    }
    public function executeDelete(sfWebRequest $request)
  {
        $login=$this->getRoute()->getObject()->getLogin();
        $login->delete();
        $partproducts=$this->getRoute()->getObject()->getPartnerproducts();
        foreach($partproducts as $product){
            $product->delete();
        }
        $partemails=$this->getRoute()->getObject()->getPartneremail();
        foreach($partemails as $email){
            $email->delete();
        }
        parent::executeDelete($request);
   }

}
